package net.aiform.account.pojo;

import java.io.Serializable;
import java.util.Date;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import net.aiform.pojo.Identity;

@Entity
@Table(name = "af_person")
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class Person extends Identity implements Serializable {
	private static final long serialVersionUID = 3677095572040861986L;
	private String password;
	private String nickName;
	private String firstname;
	private String lastname;
	private int sex;
	private Date birthday;
	private String timezone;
	private String local;
	private String lastIp;
	private Date lastTime;
	private String status;
	private String remark;
	@OneToMany(mappedBy = "person", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
	private Set<Contact> contacts;

	public void addContact(Contact contact) {
		if (!this.contacts.contains(contact)) {
			this.contacts.add(contact);
			contact.setPerson(this);
		}
	}

	public Date getBirthday() {
		return birthday;
	}

	public Set<Contact> getContacts() {
		return contacts;
	}

	public String getLastIp() {
		return lastIp;
	}

	public Date getLastTime() {
		return lastTime;
	}

	public String getLocal() {
		return local;
	}

	public String getNickName() {
		return nickName;
	}

	public String getPassword() {
		return password;
	}

	public String getRemark() {
		return remark;
	}

	public int getSex() {
		return sex;
	}

	public String getStatus() {
		return status;
	}

	public String getTimezone() {
		return timezone;
	}

	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}

	public void setContact(Set<Contact> contacts) {
		this.contacts = contacts;
	}

	public void setLastIp(String lastIp) {
		this.lastIp = lastIp;
	}

	public void setLastTime(Date lastTime) {
		this.lastTime = lastTime;
	}

	public void setLocal(String local) {
		this.local = local;
	}

	public void setNickName(String nickName) {
		this.nickName = nickName;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public void setSex(int sex) {
		this.sex = sex;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public void setTimezone(String timezone) {
		this.timezone = timezone;
	}

	public String getFirstname() {
		return firstname;
	}

	public void setFirstname(String firstname) {
		this.firstname = firstname;
	}

	public String getLastname() {
		return lastname;
	}

	public void setLastname(String lastname) {
		this.lastname = lastname;
	}

	public void setContacts(Set<Contact> contacts) {
		this.contacts = contacts;
	}

	@Override
	public String toString() {
		return "Person [birthday=" + birthday + ", contacts=" + contacts + ", firstname=" + firstname + ", lastIp=" + lastIp + ", lastTime=" + lastTime + ", lastname=" + lastname + ", local=" + local
				+ ", nickName=" + nickName + ", password=" + password + ", remark=" + remark + ", sex=" + sex + ", status=" + status + ", timezone=" + timezone + "]";
	}

}
